package com.cd.music.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

/**
 * @author yxl 余秀良
 * @version 1.0
 * @description: 用户实体类
 * @date 2018年02月07日 下午3:51
 * @address: 四川成都
 */
@Entity
@Table(name = "User")
public class User implements Serializable {
    private static final long serialVersionUID = -5191733416736261474L;
    /**
     * 主键id
     */
    @Id
    @Column(nullable = false, length = 32, unique = true, name = "id")
    private String id;
    /**
     * 用户名
     */
    @Column(name = "name", length = 30, unique = true)
    private String name;
    /**
     * 创建时间
     */
    @Column(name = "createTime", columnDefinition = "datetime default now()")
    private Date createTime;
    /**
     * 手机号码
     */
    @Column(name = "phone", length = 11, unique = true, nullable = false)
    @Pattern(regexp = "^(13[0-9]|15[0-3,5-9]|17[0135678]|18[0-9]|19[89])\\d{8}$")
    private String phone;
    /**
     * 邮箱
     */
    @Column(name = "email", length = 50)
    @Pattern(regexp = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$")
    private String email;
    /**
     * 性别
     */
    @Column(name = "gender", length = 1, columnDefinition = "tinyint(1) default 0")
    private int gender;
    /**
     * 地址
     */
    @Column(name = "address", length = 30)
    private String address;
    /**
     * 备注
     */
    @Column(name = "remark", length = 200)
    private String remark;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreateTime() {
        return (Date) createTime.clone();
    }

    public void setCreateTime(Date createTime) {
        this.createTime = (Date) createTime.clone();
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getGender() {
        return gender;
    }

    public void setGender(int gender) {
        this.gender = gender;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public User() {
    }
}